package com.li.designpattern.flyweight;

import java.util.HashMap;

public class SimpleShapeFactory {
	private static HashMap<String,Shape> shapeMap=new HashMap<String,Shape>();
	public static Shape getShape(String type){
		Shape shape = null;
		switch(type){
		case "circle":shape=shapeMap.get("circle");
		if(shape==null){
			shape=new Circle();
			shapeMap.put("circle", shape);
		}
		break;
		case "rectangle":shape=shapeMap.get("rectangle");
		if(shape==null){
			shape=new Rectangle();
			shapeMap.put("rectangle", shape);
		}
		break;
		}
		return shape;
	}
}
